﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Luna;

namespace TextDataExtractor.DEML {
	public class DataBag : Dictionary<string, object>, IDataStorage {

		public string Name { get; set; }

		public new object this[string propertyName] {
			get { return propertyName.isNotNullAndEmpty() ? (ContainsKey(propertyName) ? base[propertyName] : null) : this; }
			set { base[propertyName] = value; }
		}

		public object getDataItem(object index) {
			return index != null? this[index.ToString()] : this;
		}

		public void setDataItem(object indexer, object value) {
			this[indexer.ToString()] = value;
		}

		public override string ToString() {
			return string.Format("{0} [{1}]", Name, GetType().Name);
		}
	}
}
